<?php
/**
 * PDFエクスポート
 * @author tanaka
 * @package Controller_Action_Helper
 * @subpackage PdfExporter
 */
class Controller_Action_Helper_PdfExporter extends Zend_Controller_Action_Helper_Abstract
{
	/**
	 * CSVを出力します。
	 *
	 * @param File_Csv_CreatorAbstract $csv
	 * @return string
	 */
	public function export($pdf)
	{
		$pdf = pack("H*" ,$pdf);
		
		$response = $this->getResponse();
		$response->clearAllHeaders()->clearBody();
		$response->setHeader('Content-Type', 'application/pdf');
		$response->setHeader('Content-Length', strlen($pdf));
		$response->setHeader('Content-disposition', 'inline');
		
		$response->setRawHeader('X-Content-Type-Options: nosniff');
		$response->setRawHeader('Accept-Ranges: bytes');
		
		$response->setHeader('Expires', 0);
		$response->setRawHeader('Cache-Control:');
		$response->setRawHeader('Pragma:');
		
		$response->setBody($pdf);
		$response->sendResponse();
		exit;
	}

	/**
	 * ダイレクト
	 *
	 * @param File_Csv_CreatorAbstract $csv
	 * @return string
	 */
	public function direct($pdf)
	{
		return $this->export($pdf);
	}
}